$(function(){

	$.ajax({
		url: urlcore + "/api/withdrawSetting/withdrawSettingDetails",
		type: "get",
		dataType: 'json',
		contentType: "application/json;charset=utf-8",
		async: false,
		success:function(data){
			if (data.success == true) {
				var da = data.data;
				if(da!=null){
				$('#thisId').val(da[0].id);
				$("#startTime").val(da[0].startTime);
				$("#endTime").val(da[0].endTime);
				}
			} else if (data.code == 'OVERTIME'){
				var thisUrl = window.location.href;
				if (thisUrl.indexOf('login.html') <= -1) {
					top.window.location.href="login.html";
				}

			} else {
				if (data.msg != '空数据') {
					alert(data.msg)
				}else{
					$('#thiscount').text(0);
				}
			}

		},
		error:function() {
			alert("error");
		}
	});

});

/**
 * 去修改
 */
function toModify(){
	$("#startTime").removeAttr("readonly");
	$("#endTime").removeAttr("readonly");
	$("#modifyRate").css("display","none");
	$("#submitRate").css("display","block");
	alert("开启提现时间！");
}

/**
 * 修改
 */
function subModify() {
	var id = $('#thisId').val()
	var startTime = $('#startTime').val().trim();
	var endTime = $('#endTime').val().trim();

	$.ajax({
		url: urlcore + "/api/withdrawSetting/addOrUpdateWithdrawSetting",
		type: "post",
		data: JSON.stringify({
	        "id": id,
	        "startTime": startTime,
	        "endTime": endTime,
	        "status": 0,
	    }),
		dataType: 'json',
		contentType: "application/json;charset=utf-8",
		async: false,
		success:function(data){
			
			if (data.success == true) {
				$('#thisId').val(data.data.id);
				location.reload();
			} else if (data.code == 'OVERTIME'){
				var thisUrl = window.location.href;
				if (thisUrl.indexOf('login.html') <= -1) {
					top.window.location.href="login.html";
				}

			} else {
				if (data.msg != '空数据') {
					alert(data.msg)
				}
			}

		},
		error:function() {
			alert("error");
		}
	});
}

